#include<stdio.h>
#include<sys/types.h>
#include<stdlib.h>
#include<unistd.h>

int main()
{
    pid_t id = fork();
    if(id < 0)
    {
        printf("create process fail\n");
        return -1;
    }
    else if(id == 0)  //子进程
    {
        while(1)
        {
            printf("I am child ,my pid is %d\n",getpid());
            sleep(1);
        }
    }
    else //父进程
    {
        printf("I am parents,my pid is %d\n",getpid());
        sleep(1);
        exit(0);
    }
    return 0;
}
